package com.hotelsystem.reservations.reservations;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Scanner;

import org.junit.Test;

import com.hotelsystem.reservations.constants.Constants;
import com.hotelsystem.reservations.persons.Client;
import com.hotelsystem.reservations.persons.GenderEnum;
import com.hotelsystem.reservations.rooms.Room;
import com.hotelsystem.reservations.rooms.RoomTypesEnum;
import com.google.gson.Gson;

public class ReservationTestState {
	
	@Test
	public void testToFile() {
		
		ArrayList<Client> list = new ArrayList<Client>();
		ArrayList<Reservation> l1 = new ArrayList<Reservation>();
		Gson gson = new Gson();
		File[] listFile = new File("C:/Users/Samsung/Documents/BorislavKST/HotelSystemSVN/Reservations/Future/").listFiles();
		Reservation test = new Reservation(new Date(2015 - 1900, 5 - 1, 18), new Date(2015 - 1900, 5 - 1, 20), 
				new Client("Ivan", "Ivanov", "2345", "0888-88-88-88", GenderEnum.MALE, 25, "alabala@gmail.com", "Bulgarian", 
						"some_path", new ReservationDetails(RoomTypesEnum.ONE_PERSON_ROOM, true, true, true, 
								ReservationStatusEnum.NEW_RESERVATION, list)), new Room(35, RoomTypesEnum.ONE_PERSON_ROOM, true));
		
		//new ReservationManagement().AddReservationToFile(test);
		for (File file : listFile) {
			try (Scanner sc = new Scanner(file)) {
				Reservation res = gson.fromJson(sc.next(), Reservation.class);
		l1.add(res);
		}catch (FileNotFoundException e) {
			System.out.println("Error reading file " + file.getName());
			e.printStackTrace();
		}
		}
		assertFalse("Expected the same values: ", test.toJson().equals(l1.get(0).toJson()));
		assertFalse("Expected the same values: ", test.toJson().equals(l1.get(1).toJson()));
		assertFalse("Expected the same values: ", test.toJson().equals(l1.get(2).toJson()));
		assertTrue("Expected the same values: ", test.toJson().equals(l1.get(3).toJson()));
	}
}
